import threading, time


def saySorry():
    print("子线程%s启动" % (threading.current_thread().name))  # 当前线程的名字
    time.sleep(1)
    print("我能吃饭了吗？")


class MyThread(threading.Thread):
    def run(self):
        for i in range(5):
            print(i)



if __name__ == "__main__":
    print('主线程%s启动' % (threading.current_thread().name))
    for i in range(5):
        t = threading.Thread(target=saySorry)  # Thread()：指定线程要执行的代码
        t.start()
    t1 = MyThread()
    t2 = MyThread()
    t1.start()
    t2.start()
